/*
 @desc: 首页数据处理
 @date: 2021/12/28
 */

#import "HomeViewModel.h"

@interface HomeViewModel()

@property(nonatomic,strong)DiskStorage * mStore;
@property(nonatomic,strong)NSMutableArray * mDataSource;

@end

@implementation HomeViewModel

- (void)reloadData {
    [self reset];
    
    NSArray * data = [self.mStore fetchData];
    [self.mDataSource addObjectsFromArray:data];
    
    self.reloadComplate();
}

- (NSInteger)sectionCount {
    return 1;
}
- (NSInteger)cellCount:(NSInteger)section {
    return self.mDataSource.count;
}
- (NSURL *)cellDataFor:(NSIndexPath *)index {
    return self.mDataSource[index.row];
}


-(void)reset {
    [self.mDataSource removeAllObjects];
}

//MARK: 懒加载
-(DiskStorage *)mStore {
    if (nil == _mStore) {
        _mStore = [[DiskStorage alloc] init];
    }
    return _mStore;
}
-(NSMutableArray *)mDataSource {
    if (nil == _mDataSource) {
        _mDataSource = [NSMutableArray new];
    }
    return _mDataSource;
}
@end
